package com.yanqu.road.server.cmd.clinic;

import com.yanqu.road.pb.clinic.ClinicProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.clinic.ClinicModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2021/3/3 11:56
 */
@Cmd(code = GameProtocol.S_CLINIC_RECEPT_PATIENT, desc = "接待病人")
public class ReceptPatientCmd extends AbstractCommand {
    private boolean isOneKey;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ClinicProto.ReceptPatientReqMsg msg = ClinicProto.ReceptPatientReqMsg.parseFrom(packet.getBytes());
        isOneKey = msg.getIsOnekey();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        player.getModule(ClinicModule.class).offlineCure();
        ClinicProto.ReceptPatientRespMsg.Builder respMsg = ClinicProto.ReceptPatientRespMsg.newBuilder();
        if (isOneKey) {
            player.getModule(ClinicModule.class).oneKeyReceptPatient(respMsg, false);
        } else {
            player.getModule(ClinicModule.class).receptPatient(respMsg);
        }
        player.sendPacket(ClientProtocol.U_CLINIC_RECEPT_PATIENT, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {
    }
}
